package com.example.killer.defaultadapter;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.ListView;

import com.example.killer.defaultadapter.Adapter.MyAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class MainActivity extends AppCompatActivity {

    private ListView list;
    private List<Map<String, Object>> values;
    private MyAdapter adapter;
    private int[] imgs = new int[]{R.drawable.open_dir, R.drawable.close_dir, R.drawable.image_file, R.drawable.mp3_file, R.drawable.mp4_file, R.drawable.txt_file};
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       //初始化Globals，才能在后面拿到
        Globals.init(this);
        setContentView(R.layout.activity_main);

        list = (ListView) findViewById(R.id.lv_list);


        Random r = new Random();
        values = new ArrayList<>();
        for(int i=0;i<30;i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("title", "测试标题" + i);
            map.put("time", "2012-03-02 动作");
            map.put("img", imgs[r.nextInt(imgs.length)]);
            values.add(map);
        }
        adapter = new MyAdapter(this, values);
        list.setAdapter(adapter);

    }
}
